<template>
  <div class="wrapper" ref="wrapper">
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
import BScroll from 'better-scroll'

export default {
  name: "Scroll",
  data() {
    return {
      scroll: null,
    }
  }, props: {
    probeTypeNum: {
      type: Number,
      default() {
        return 0
      }
    },
    pullUpLoad:{
      type:Boolean,
      default() {
        return false;
      }
    }
  },
  mounted() {
    this.scroll = new BScroll(this.$refs.wrapper, {
      probeType: this.probeTypeNum,
      pullUpLoad:this.pullUpLoad,
      click:true
    })

    //监控滑动
    this.scroll.on('scroll', (position) => {
      this.$emit('scroll', position)
    })
    //监控到低刷新
    this.scroll.on('pullingUp', () => {
      this.$emit('pullingUp')
    })
  },
  methods: {
    scrollTo(x, y, time = 300) {
     this.scroll&& this.scroll.scrollTo(x, y, time)
    },
    finishPullUp(){
     this.scroll&& this.scroll.finishPullUp();
    },
    refresh(){
      this.scroll.refresh();
    }
  }
}
</script>

<style scoped>

</style>